package com.heima.admin.controller;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.heima.admin.dto.SensitiveDto;
import com.heima.admin.entity.AdSensitive;
import com.heima.common.dto.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.heima.admin.service.IAdSensitiveService;
import java.util.List;
import java.util.Map;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 敏感词信息表 前端控制器
 * </p>
 *
 * @author mcm
 * @since 2021-05-18
 */
@RestController
@RequestMapping("/api/v1/sensitive")
@Api(tags = "敏感词信息表接口")
@CrossOrigin
public class AdSensitiveController{

    @Autowired
    private IAdSensitiveService adSensitiveService;


    @PostMapping("/list")
    @ApiOperation(value = "查询敏感词", notes = "author:mcm")
    public ResponseResult findListByName(@RequestBody SensitiveDto dto){
        return adSensitiveService.findListByName(dto);
    }

    @PostMapping("/save")
    @ApiOperation(value = "添加敏感词", notes = "author:mcm")
    public ResponseResult saveSensitive(@RequestBody AdSensitive sensitive){
        return adSensitiveService.saveSensitive(sensitive);
    }

    @PostMapping("/update")
    @ApiOperation(value = "修改敏感词", notes = "author:mcm")
    public ResponseResult updateSensitive(@RequestBody AdSensitive sensitive){
        return adSensitiveService.updateSensitive(sensitive);
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除敏感词", notes = "author:mcm")
    public ResponseResult deleteSensitive(@PathVariable("id") Integer id){
        adSensitiveService.removeById(id);
        return ResponseResult.okResult();
    }
}
